/*
ID: khymill1
PROG: sprime 
LANG: C++
*/
#include <string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>
using namespace std;

vector<int> table;

bool isPrime(int input)
{
    if (input == 1)
        return false;
    for (int i = 2; i*i <= input; i++)
        if (input%i == 0)
            return false;
    return true;
}

bool prime(int input)
{
    if (input == 1)
        return false;
    int factor = 1;
    while(input > factor && input/factor > 0) {
        //cout << factor << endl;
        int num = input/factor;
        //cout << input << " " << num << endl;
        if (!isPrime(num))
            return false;
        factor *= 10;
    }
    return true;
}
void genSprime(int index, int k, int cur)
{
    if (index == k) {
        if (prime(cur)) {
            table.push_back(cur);
        }
        return;
    }

    for (int i = 1; i <= 9; i++) {
        genSprime(index+1, k, cur*10+i);
    }
}

int main()
{
    ifstream fin("sprime.in");
    ofstream fout("sprime.out");
    int k;
    fin >> k;
    cout << k << endl;
    int cur = 0;
    genSprime(0, k, cur);
    sort(table.begin(), table.end());
    for (int i = 0; i < table.size(); i++)
            fout << table[i] << endl;
    return 0;
}                                          
